#ifndef _D_LIST_VER4_
#define	_D_LIST_VER4_
#include "list_pthread.h"

struct d_list_node;
struct d_list_head;
typedef int (* DListVisitFunc)(void *data, void *ctx);
typedef int (* DListCmpFunc)(void *da, void *db);
typedef int (* DListDestroyData)(void *data);
typedef DListLock* (* DListMultiThreadLockCreate)(void);

typedef struct d_list_node DNode;
typedef struct d_list_head DList;

#if 1
struct d_list_head {
    struct d_list_node *first;
    DListLock *lock;
    DListCmpFunc 	cmp;
    DListDestroyData	destroy;
};
#endif

typedef int DListRet;

extern DListRet init_list(DList *head, DListCmpFunc cmp, DListDestroyData destroy, DListMultiThreadLockCreate create);
extern DListRet destroy_list(DList *head);
extern DListRet append_to_list(DList *head, void *data);
extern DListRet remove_node(DList *head, void *data);
extern DListRet find_node(DList *head, void *data, void *result);
extern DListRet list_for_each(DList *head, DListVisitFunc func, void *ctx);
#endif

